package com.lzj.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;

/**
 * 延迟任务线程池配置类
 * @author 程就人生
 * @Date
 */
@Configuration
public class TheadPoolConfig {

  @Bean("threadPoolTaskExecutor")
  public ThreadPoolTaskExecutor threadPoolTaskExecutor(){
    // 定时任务线程池
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    // 线程池大小
    executor.setCorePoolSize(5);
    // 线程执行前缀
    executor.setThreadNamePrefix("threadPoolTaskExecutor-");
    executor.initialize();
    return executor;
  }
}
